$(function(){

	var urlParams;

	parseUrl = function () {
	    var match,
	        pl     = /\+/g,  // Regex for replacing addition symbol with a space
	        search = /([^&=]+)=?([^&]*)/g,
	        decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
	        query  = window.location.search.substring(1);

	    urlParams = {};
	    while (match = search.exec(query))
	        urlParams[match[1]] = match[2];
	};

	(window.onpopstate = parseUrl)();

	var url = new Array();
	for(param in urlParams){
		if(param != "lang"){
			url.push(param+"="+urlParams[param]);
		}
	}

	if(url.length != 0){
		$("#toEng").attr("href","?"+url.join('&')+"&lang=en");
		$("#toChi").attr("href","?"+url.join('&')+"&lang=zh");
	}

});
